Project done by Michela Pirozzi MAT:732531 and Sara Ferioli MAT:733105
Given the features in the dataset, what is the best combination to have a new contract? Was the feature combination the same even before covid?
Predict number of contracts. Is the number of contracts predicted for the future in 2019 the same or similar to the actual data given the occurrence of COVID?
# Method that allow to extract only specific (time) years
# syntax:
# df: dataframe
# time: regex. es: r'20(18|19|20|21)' or r'2020'
def set_years(df,time):
df.replace(r'..(/|-)..(/|-)','',regex=True, inplace = True)
df = df[df["DATA"].str.match(time)==True]
return df
# Method that creates an animated histogram
# syntax:
# df: dataframe
# column: column on which you want to group
# time: column on which you want to animate
def time_for_column(df, column, time):
df_merge_col = df.groupby([column, time]).size().sort_values(ascending=False).reset_index(name='count')
tot = px.bar(df_merge_col, x=column, y='count', animation_frame=time,
animation_group=column, color=column)
tot.update_layout(title='')
tot.update_xaxes(categoryorder='total ascending')
tot.show()
# Method for creating a geographic map.
# syntaxt:
# df: dataframe
# column: column on which you want to group
def map_fig(df,column):
df_merge_col = df.groupby([column, "latitudine","longitudine"]).size().reset_index(name='count')
df_merge_col['count']=df_merge_col['count']/100
df_merge_col['count']=list(map(int, df_merge_col['count']))
fig = px.scatter_mapbox(df_merge_col, lat="latitudine", lon="longitudine", color=column,
size="count", zoom=10)
fig.update_layout(mapbox_style="open-street-map")
fig.show()
# Load dataset
attivati = pd.read_csv("Rapporti_di_lavoro_attivati.csv")
attivati.head()
| DATA | GENERE | ETA | SETTOREECONOMICODETTAGLIO | TITOLOSTUDIO | CONTRATTO | MODALITALAVORO | PROVINCIAIMPRESA | ITALIANO | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 09/05/2020 | F | 60 | Attività di famiglie e convivenze come datori ... | NESSUN TITOLO DI STUDIO | LAVORO DOMESTICO | TEMPO PIENO | BERGAMO | UCRAINA |
| 1 | 12/07/2019 | M | 43 | Gestioni di funicolari, ski-lift e seggiovie s... | LICENZA MEDIA | LAVORO A TEMPO DETERMINATO | TEMPO PIENO | BERGAMO | ITALIA |
| 2 | 05/06/2013 | F | 20 | Fabbricazione di altre apparecchiature elettri... | LICENZA MEDIA | APPRENDISTATO PROFESSIONALIZZANTE O CONTRATTO ... | TEMPO PIENO | BERGAMO | ITALIA |
| 3 | 12/03/2010 | F | 28 | Alberghi | DIPLOMA DI ISTRUZIONE SECONDARIA SUPERIORE CH... | LAVORO INTERMITTENTE A TEMPO DETERMINATO | NON DEFINITO | BERGAMO | ITALIA |
| 4 | 06/04/2021 | F | 49 | Rifugi di montagna | LICENZA MEDIA | LAVORO INTERMITTENTE | NON DEFINITO | BERGAMO | ITALIA |
# Show the graph
time_for_column(dati,"CONTRATTO","DATA")
# Show the graph
px.bar(df_merge_col, 'SETTOREECONOMICODETTAGLIO', 'count',
color='SETTOREECONOMICODETTAGLIO', animation_frame='DATA',
category_orders={'DATA':['2018', '2019', '2020', '2021']}, title='', range_y=[0, 60000])
We can see that housework ('Attività di famiglie e convivenze come datori di lavoro per personale domestico') during the covid has increased. Instead, hotel ('Alberghi') and catering ('Ristorazione con somministrazione') sector have decreased.
# Show the graph
map_fig(dati,"CONTRATTO")